Component({
  properties: {
    // nmg06 | nmg01 | nmg04 | nmg05 | nmg03 | gengduo | a-gengduo1x | home11 | home14 | home15 | home10 | home12 | home13 | home8 | home7 | home6 | home4 | home3 | home5 | home1 | home2 | my1 | my3 | my5 | my2 | my4 | sbk2 | sbk5 | sbk1 | sbk4 | sbk7 | sbk3 | sbk6 | qzzp1 | shebaoqiafuwu_shebaoqiabuban | ldgx7 | ldgx1 | ldgx4 | ldgx6 | ldgx2 | ldgx3 | ldgx5 | rsrc5 | rsrc1 | rsrc3 | rsrc4 | rsrc2 | jycy7 | jycy1 | jycy2 | jycy8 | jycy5 | jycy6 | jycy3 | jycy4 | shbx17 | shbx16 | shbx15 | shbx1 | shbx2 | shbx3 | shbx4 | shbx5 | shbx6 | shbx7 | shbx8 | shbx9 | shbx10 | shbx11 | shbx12 | shbx13 | shbx14 | xiaoxi | shouye | shouye-copy | icon-test | icon-myself
    name: {
      type: String,
    },
    // string | string[]
    color: {
      type: null,
      observer: function(color) {
        this.setData({
          colors: this.fixColor(),
          isStr: typeof color === 'string',
        });
      }
    },
    size: {
      type: Number,
      value: 18,
      observer: function(size) {
        this.setData({
          svgSize: size,
        });
      },
    },
  },
  data: {
    colors: '',
    svgSize: 18,
    quot: '"',
    isStr: true,
  },
  methods: {
    fixColor: function() {
      var color = this.data.color;
      var hex2rgb = this.hex2rgb;

      if (typeof color === 'string') {
        return color.indexOf('#') === 0 ? hex2rgb(color) : color;
      }

      return color.map(function (item) {
        return item.indexOf('#') === 0 ? hex2rgb(item) : item;
      });
    },
    hex2rgb: function(hex) {
      var rgb = [];

      hex = hex.substr(1);

      if (hex.length === 3) {
        hex = hex.replace(/(.)/g, '$1$1');
      }

      hex.replace(/../g, function(color) {
        rgb.push(parseInt(color, 0x10));
        return color;
      });

      return 'rgb(' + rgb.join(',') + ')';
    }
  }
});
